package org.example.controller;

import org.example.api.IUserService;
import org.example.api.entity.User;
import org.example.service.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: Re
 * @Date: 2021/4/18 15:31
 */
@WebServlet("/check")
public class CheckAllUserServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;utf-8");
        req.setCharacterEncoding("UTF-8");
        IUserService iUserService = new UserServiceImpl();
        List<User> users = null;
        users = iUserService.checkAllUser();
        HttpSession session = req.getSession();
        session.setAttribute("users",users);
        req.getRequestDispatcher("success.jsp").forward(req,resp);
    }
}
